<template>
</template>
<script setup>
import { getCurrentInstance, onMounted, onUpdated, useAttrs } from 'vue';

const self = getCurrentInstance();
const attrs = useAttrs();

onMounted(() => {
  const observer = new MutationObserver(syncAttrs);

  syncAttrs();

  function syncAttrs() {
    observer.disconnect();
    const parent = self.vnode.el.parentElement.closest('[slot-attrs]');
    if (!parent) {
      console.warn('No element found to inject slot attributes!');
      return;
    }
    for (const name in attrs) {
      if (name === 'class') {
        attrs[name].match(/[\w-]+/g).forEach(name => parent.classList.add(name));
      } else {
        parent.setAttribute(name, attrs[name]);
      }
    }
    observer.observe(parent, { attributes: true });
  }
})
</script>
<style lang="">

</style>